- /******************************************************************************/
- #define F_CPU 16000000UL
- #include <avr/io.h>
- #include <util/delay.h>
- #include <avr/sleep.h>
- #include <avr/interrupt.h>
- /******************************************************************************/
- int main(void)
- {
- cli();
- DDRD &= ~_BV(DDRD0); // set as input
- PORTD |= _BV(PORTD0); // enable pull-up
- DDRB |= _BV(DDB5);
- PORTB |= _BV(PINB5); // initialize to high
- PCICR |= _BV(PCIE2); // set PCIE2 to enable PCMSK2 scan
- PCMSK2 |= _BV(PCINT16); // set PCINT16 to trigger an interrupt on state change
- sei(); // turn on interrupts
- while (1) asm volatile ("nop"::);
- }
- /******************************************************************************/
- ISR (PCINT2_vect) {}
- /******************************************************************************/